package aptech.eproject.logictics.db;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Set;

/**
 * The persistent class for the PACKAGE database table.
 * 
 */
@Entity
@Table(name = "PACKAGE")
public class Package implements Serializable {

    private static final long serialVersionUID = 1L;
    private int packageId;
    private DeliveryStatus deliveryStatus;
    private boolean isDeleted;
    private double weight;
    private Delivery delivery;
    private Set<TripPackage> tripPackages;
    private Set<Warehouse> warehouses;

    public Package() {
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "PACKAGE_ID")
    public int getPackageId() {
        return this.packageId;
    }

    public void setPackageId(int packageId) {
        this.packageId = packageId;
    }

    @Enumerated(EnumType.STRING)
    @Column(name = "DELIVERY_STATUS", nullable = true)
    public DeliveryStatus getDeliveryStatus() {
        return deliveryStatus;
    }

    public void setDeliveryStatus(DeliveryStatus deliveryStatus) {
        this.deliveryStatus = deliveryStatus;
    }

    @Column(name = "IS_DELETED", nullable = true)
    public boolean getIsDeleted() {
        return this.isDeleted;
    }

    public void setIsDeleted(boolean isDeleted) {
        this.isDeleted = isDeleted;
    }

    @Column(name = "WEIGHT", nullable = false)
    public double getWeight() {
        return this.weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    //bi-directional many-to-one association to Delivery
    @ManyToOne
    @JoinColumn(name = "DELIVERY_ID", nullable = false)
    public Delivery getDelivery() {
        return this.delivery;
    }

    public void setDelivery(Delivery delivery) {
        this.delivery = delivery;
    }

    //bi-directional many-to-one association to TripPackage
    @OneToMany(mappedBy = "package", fetch = FetchType.EAGER)
    public Set<TripPackage> getTripPackages() {
        return this.tripPackages;
    }

    public void setTripPackages(Set<TripPackage> tripPackages) {
        this.tripPackages = tripPackages;
    }

    public TripPackage addTripPackage(TripPackage tripPackage) {
        getTripPackages().add(tripPackage);
        return tripPackage;
    }

    public TripPackage removeTripPackage(TripPackage tripPackage) {
        getTripPackages().remove(tripPackage);
        tripPackage.setPackage(null);
        return tripPackage;
    }
    //bi-directional many-to-one association to Warehouse

    @OneToMany(mappedBy = "package", fetch = FetchType.EAGER)
    public Set<Warehouse> getWarehouses() {
        return this.warehouses;
    }

    public void setWarehouses(Set<Warehouse> warehouses) {
        this.warehouses = warehouses;
    }

    public Warehouse addWarehouse(Warehouse warehouse) {
        getWarehouses().add(warehouse);
        return warehouse;
    }

    public Warehouse removeWarehouse(Warehouse warehouse) {
        getWarehouses().remove(warehouse);
        warehouse.setPackage(null);
        return warehouse;
    }
}
